package com.hengpeng.itfin.exception;

import java.io.PrintStream;
import java.io.PrintWriter;

import com.hengpeng.common.exception.TransException;

/**
 * <pre>
 * 支付异常类
 * </pre>
 * @author linriqing
 * @version 1.0, 2006-8-8
 */
public class PaymentException extends TransException
{
	private static final long serialVersionUID = 7227824468396169434L;

	/**
	 * 原始异常
	 */
	private Exception originalException = null;

	/**
	 * 构造函数
	 * @param e 原始异常实例
	 */
	public PaymentException(Exception e)
	{
		super(e.getCause());
		this.setOriginalException(e);
	}

	/**
	 * 构造函数
	 * @param message 异常信息
	 */
	public PaymentException(String message)
	{
		super(message);
	}

	/**
	 * 构造函数
	 * @param message 异常信息
	 * @param e 原始异常实例
	 */
	public PaymentException(String message, Exception e)
	{
		super(message, e);
		this.setOriginalException(e);
	}

	public PaymentException(String errCode, String message)
	{
		super(errCode, message);
	}

	public PaymentException(String errCode, String message, Throwable cause)
	{
		super(errCode, message, cause);
	}

	/**
	 * @return originalException
	 * @see com.hengpeng.paysystem.exception.PaymentException#originalException
	 */
	public Exception getOriginalException()
	{
		return originalException;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Throwable#printStackTrace()
	 */
	public void printStackTrace()
	{
		super.printStackTrace();
		if (this.originalException != null)
		{
			this.originalException.printStackTrace();
		}
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
	 */
	public void printStackTrace(PrintStream s)
	{
		super.printStackTrace(s);
		if (this.originalException != null)
		{
			this.originalException.printStackTrace(s);
		}
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
	 */
	public void printStackTrace(PrintWriter s)
	{
		super.printStackTrace(s);
		if (this.originalException != null)
		{
			this.originalException.printStackTrace(s);
		}
	}

	/**
	 * @param originalException originalException
	 * @see com.hengpeng.paysystem.exception.PaymentException#originalException
	 */
	public void setOriginalException(Exception originalException)
	{
		this.originalException = originalException;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Throwable#toString()
	 */
	public String toString()
	{
		String message = super.toString();
		if (this.originalException != null)
		{
			message = message + this.originalException.toString();
		}
		return message;
	}

}
